/*
 * Unit.cc
 *
 *  Created on: Mar 9, 2011
 *      Author: topcoder
 */

#include "Unit.h"
#include "math.h"
#include "float.h"

Unit::Unit(const unsigned int ratio2BaseUnit, const string name):\
    ratio2BaseUnit_m(ratio2BaseUnit),name_m(name)
{
}

unsigned int Unit::toAmountInBaseUnit(const unsigned int amount) const
{
    return amount*ratio2BaseUnit_m;
}

unsigned int Unit::toAmountInThisUnit(const unsigned int amount) const
{
    return (amount/ratio2BaseUnit_m);
}

ostream& operator << (ostream& os, const Unit& unit)
{
    os << unit.name_m;

    return os;
}
